package com.year_23.may;

/**
 * @author: jsh
 * @create: 2023/5/8 22:39
 * @Description:  153 寻找旋转排序数组中的最小值
 *
 * @FileName: Day08_2
 * @History:
 * @自定义内容：
 */
public class Day08_2 {

    public static void main(String[] args) {
        int[] arr = {1,2,3,};
        System.out.println(findMin(arr));
    }

    public static int findMin(int[] arr){
        int right = arr.length-1;
        int left = 1, temp = arr[0], res = 0;
        while (left <= right){
            int mid = left + (right - left)/2;
            if (arr[mid] > temp){
                left = mid +1;
            }else {
                res = mid;
                right = mid -1;
            }
        }
        return arr[res];
    }

    // 33 搜索旋转排序数组
    public int search(int[] nums, int target) {
        int left = 0, right = nums.length-1;
        while (left <= right){
            int mid = left +(right - left)/2;
            if (nums[mid] == target)return mid;
            if (nums[mid] > target){

            }
        }
        return -1;

    }
}
